﻿// =====================================================================
// <copyright file="SettingsUnitOfWork.cs" author="David R. Guindo">
//    Copyright (C) 2013. All rights reserved.
// </copyright>
// =====================================================================

namespace AppBlock.Config
{
   using System.Data.Entity;
   using System.Data.Entity.ModelConfiguration;
   using System.Data.Entity.ModelConfiguration.Conventions;

   public class SettingsUnitOfWork : DbContext
   {
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
         modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
         modelBuilder.Configurations.Add(new SettingItemDataMap());
      }
   }

   /// <summary>
   /// Class SettingItemDataMap.
   /// </summary>
   public class SettingItemDataMap : EntityTypeConfiguration<SettingItem>
   {
      public SettingItemDataMap()
      {
         HasKey(p => p.Key);
         HasKey(p => p.Module);
      }
   }
}